//package com.mmy.fta.trade.server.service.impl;
//
//import com.mmy.fta.trade.server.dto.DriverOrderMsgDTO;
//import com.mmy.fta.trade.server.dto.ShipperOrderMsgDTO;
//import com.mmy.fta.usercenter.api.UserService;
//import io.manbang.ironman.api.mq.producer.Message;
//import io.manbang.ironman.api.mq.producer.MessageReference;
//import io.manbang.ironman.api.mq.producer.Producer;
//import io.manbang.ironman.api.mq.producer.Result;
//import io.manbang.ironman.api.mq.producer.ResultStatus;
//import io.manbang.ironman.api.rpc.annotation.RPCReference;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//
///**
// * @author qiang.lin
// * @since 2021/11/4
// */
//@Service
//@Slf4j
//public class MessageProduceService {
//
//    @MessageReference(key="fta-trade-producer")
//    Producer tradeMQProducer;
//
//    @RPCReference
//    UserService userService;
//
//
//    public void produceOrderMsg(String orderNumber, Integer deposit, String loadTime, String loadAddress , String phoneNumber,String cargoName,
//                                String driverName,String unloadAddress,String shipperOpenId,Integer orderStatus){
//
//        if(orderStatus == 4 ){
//            DriverOrderMsgDTO driverOrderMsgDTO =new DriverOrderMsgDTO();
//
//            driverOrderMsgDTO.setOrderNumber(orderNumber);
//            driverOrderMsgDTO.setDeposit(deposit);
//            driverOrderMsgDTO.setLoadTime(loadTime);
//            driverOrderMsgDTO.setLoadAddress(loadAddress);
//            driverOrderMsgDTO.setDriverPhoneNumber(phoneNumber);
//            driverOrderMsgDTO.setOrderStatus(orderStatus);
//
//            Result res1 = sendOrderMQToDriver(driverOrderMsgDTO);
//
//            if(res1.getStatus() == ResultStatus.SEND_OK){
//                log.info("发送driver-mq成功：driverOrderMsgDTO:{}",driverOrderMsgDTO);
//            }
//        }
//
//        if(orderStatus == 1 || orderStatus == 3 || orderStatus == 6){
//
//            ShipperOrderMsgDTO shipperOrderMsgDTO = new ShipperOrderMsgDTO();
//
//            shipperOrderMsgDTO.setOrderNumber(orderNumber);
//            shipperOrderMsgDTO.setCargoName(cargoName);
//            shipperOrderMsgDTO.setDriverName(driverName);
//            shipperOrderMsgDTO.setLoadAddress(loadAddress);
//            shipperOrderMsgDTO.setUnloadingAddress(unloadAddress);
//            shipperOrderMsgDTO.setOrderStatus(orderStatus);
//
//            String shipperPhoneNumber=userService.queryShipperPhoneNumber(shipperOpenId);
//            shipperOrderMsgDTO.setShipperPhoneNumber(shipperPhoneNumber);
//
//            Result res2 = sendOrderMQToShipper(shipperOrderMsgDTO);
//
//            if(res2.getStatus() == ResultStatus.SEND_OK){
//                log.info("发送shipper-mq：shipperOrderMsgDTO:{}",shipperOrderMsgDTO);
//            }
//
//        }
//    }
//    public void produceOrderMsg(String orderNumber,Integer orderStatus){
//
//        if(orderStatus == 2 || orderStatus == 20 || orderStatus == 4 || orderStatus == 7){
//            DriverOrderMsgDTO driverOrderMsgDTO = new DriverOrderMsgDTO();
//            //货主同意 拒绝 取消 收货 向司机发websocket
//            driverOrderMsgDTO.setOrderNumber(orderNumber);
//            driverOrderMsgDTO.setOrderStatus(orderStatus);
//
//            sendOrderMQToDriver(driverOrderMsgDTO);
//        }
//
//        if(orderStatus == 1 || orderStatus == 3 || orderStatus == 5 || orderStatus == 6){
//            ShipperOrderMsgDTO shipperOrderMsgDTO = new ShipperOrderMsgDTO();
//            //司机下单 取消 装货 卸货 向货主发websocket
//            shipperOrderMsgDTO.setOrderNumber(orderNumber);
//            shipperOrderMsgDTO.setOrderStatus(orderStatus);
//
//            sendOrderMQToShipper(shipperOrderMsgDTO);
//        }
//    }
//
//    private Result sendOrderMQToDriver(DriverOrderMsgDTO driverOrderMsgDTO) {
//        Message message = Message.normal("fta-training-trade").tag("fta-order-driver").payload(driverOrderMsgDTO).build();
//        return tradeMQProducer.send(message);
//    }
//
//
//    /**
//     *司机下单后，向货主发送信息
//     * @param shipperOrderMsgDTO
//     * @return
//     */
//    public Result sendOrderMQToShipper(ShipperOrderMsgDTO shipperOrderMsgDTO) {
//        Message message = Message.normal("fta-training-trade").tag("fta-order-shipper").payload(shipperOrderMsgDTO).build();
//        return tradeMQProducer.send(message);
//    }
//}
